package com.aiwei.tdjk.service.impl;

import com.aiwei.tdjk.bean.Pager;
import com.aiwei.tdjk.dao.extend.LoginLogExtendMapper;
import com.aiwei.tdjk.dto.request.LoginLogPagerRequest;
import com.aiwei.tdjk.entity.LoginLog;
import com.aiwei.tdjk.service.LoginLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LoginLogServiceImpl implements LoginLogService{

    @Autowired
    private LoginLogExtendMapper loginLogExtendMapper;



    @Override
    public Pager<LoginLog> find(LoginLogPagerRequest request) {
        request.webParamConvert();
        List<LoginLog> list = loginLogExtendMapper.find(request);
        int totalCount = loginLogExtendMapper.getTotalCount(request);
        Pager<LoginLog> pager = new Pager<>();
        pager.setPageNumber(request.getPageNumber());
        pager.setPageSize(request.getPageSize());
        pager.setList(list);
        pager.setTotalCount(totalCount);
        return pager;
    }
    /**
     * 新增
     *
     * @param loginLog
     * @return
     */
    @Override
    public int add(LoginLog loginLog) {
        return loginLogExtendMapper.insertSelective(loginLog);
    }

    /**
     * 更新
     *
     * @param loginLog
     */
    @Override
    public void update(LoginLog loginLog) {
        loginLogExtendMapper.updateByPrimaryKeySelective(loginLog);
    }

    /**
     * 删除
     *
     * @param id
     */
    @Override
    public void delete(Long id) {
        loginLogExtendMapper.deleteByPrimaryKey(id);
    }

}
